package com.lucas.aop;

import org.I0Itec.zkclient.ZkClient;
import org.apache.log4j.Logger;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.context.annotation.EnableAspectJAutoProxy;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 参考网址:还可以了解一下postman怎么使用
 * https://blog.csdn.net/qq_35387940/article/details/85261279
 */
@Component
@Aspect
public class ZookeeperAop {

    private static final Logger logger = Logger.getLogger(ZookeeperAop.class);

    //配置切点
    @Pointcut(value = "@annotation(com.lucas.annation.ZookeeperServer)")
    public void startup(){}

    @After(value="startup()")
    public void doBefore(){
        ZkClient zkClient = new ZkClient("192.168.162.129:2181");
        System.out.println("zookeeper 通信建立来了");
        zkClient.createPersistent("/zookepperConfig/host1",true);
        zkClient.createEphemeral("/zookepperConfig/host1/ip","127.0.0.1");
        zkClient.createEphemeral("/zookepperConfig/host1/port","8099");
//        List<String> children = zkClient.getChildren("/zookeeper");

    }

}
